<include file="Public/header.html" />
</head>
<style>
.font_color{color: #ff5722;}
.layui-tab-content .layui-form-label{width: 180px;}
.layui-tab-content .layui-input-block{margin-left: 180px;}
.delate_img{width: 26px;position: absolute;height: 26px;line-height: 27px;background: rgba(0,0,0,0.7);text-align: center;top: -10px;
    right: -10px;color: #fff;font-size: 24px;cursor: pointer;border-radius: 100%;}
</style>
<body>
	<div class="x-nav">
        <span class="layui-breadcrumb">
          <a><cite>首页</cite></a>
          <a><cite>系统设置</cite></a>
          <a><cite>基础规则</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;height:30px;padding: 0 15px;"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
   	</div>
	<div class="x-body">
		<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
			<!--<ul class="layui-tab-title">
				<li class="<?php if($flag=='system'){echo 'layui-this';}?>">
					<a target="_self" href="{:U('Home/Web/System/system',array('flag'=>'system'))}">系统设置</a>
				</li>
			</ul>-->
			<div style="padding: 10px;">
				<!--系统设置-->
				<div class="layui-tab-item <?php if($flag=='system'){echo'layui-show';}?>">
					<form name="system" id="system" class="layui-form layui-form-pane" >
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">手机端名称</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="m_name" lay-verify="required" value="{$list['m_name']}" autocomplete="off" class="layui-input">
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">Appid</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="appid" lay-verify="required" value="{$list['appid']}" autocomplete="off" placeholder="请填写微信appid" class="layui-input">
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">Appsecret</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="secret" lay-verify="required" value="{$list['secret']}" autocomplete="off" placeholder="请填写微信appsecret" class="layui-input">
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">客服</label>
						    <button type="button" class="layui-btn" id="upload_kf">
								<i class="layui-icon">&#xe67c;</i>上传图片
							</button>
							<div class="layui-input-block" style="margin-left: 145px;">
								<input id="kf_img_val" name="kf_img" type="hidden" value="{$list['kf_img']}" />
								<?php if(!empty($list['kf_img'])){ ?>
								<img id="kf_img" style="width: 200px;height: 200px;" src="{$list['kf_img']}" />
								<?php }else{ ?>
								<img id="kf_img" style="width: 200px;height: 200px;" src="__ROOT__/Public/images/z_add.png" />
								<?php } ?>
							</div>
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">分享海报</label>
						    <button type="button" class="layui-btn" id="upload_posters">
								<i class="layui-icon">&#xe67c;</i>上传图片
							</button>
							<div class="layui-input-block" style="margin-left: 145px;">
								<input id="posters_val" name="posters" type="hidden" value="{$list['posters']}" />
								<?php if(!empty($list['posters'])){ ?>
								<img id="posters" style="width: 200px;height: 200px;" src="{$list['posters']}" />
								<?php }else{ ?>
								<img id="posters" style="width: 200px;height: 200px;" src="__ROOT__/Public/images/z_add.png" />
								<?php } ?>
							</div>
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">首页标题</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="title" value="{$list['title']}" autocomplete="off" placeholder="请填写首页标题" class="layui-input">
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">分销比例</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="one_fx" value="{$list['one_fx']}" autocomplete="off" placeholder="单位：%" class="layui-input">
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">模式选择</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						    	<select name="login_type" id="login_type">
							    	<option value="1" <if condition="1 eq $list['login_type']">selected</if> >公众号模式</option>	
							    	<option value="2" <if condition="2 eq $list['login_type']">selected</if> >手机号模式</option>	
							    </select>	
						    </div>				    
						</div>
								
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">验证码API账号</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="code_api_user" value="{$list['code_api_user']}" autocomplete="off" class="layui-input">
						      	<strong style="color: red;">
						      		请在薪推盟代理商后台查看
						      		<a href="http://www.xintm.cn" target="_blank">点击注册</a>
						      		<a href="https://www.xqzbk.top/jishu/3134.html" target="_blank">查看教程</a><br/>
						      	</strong>
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">验证码API密码</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="code_api_pwd" value="{$list['code_api_pwd']}" autocomplete="off" class="layui-input">
						      	<strong style="color: red;">请在薪推盟代理商后台查看<br/></strong>
						    </div>				    
						</div>
						
						<div class="layui-form-item">
						   	<label class="layui-form-label" style="width: 145px;">验证码发送</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						      	<input type="text" name="msg" value="{$list['msg']}" autocomplete="off" class="layui-input">
						      	<strong style="color: red;">示例：【薪推盟】您的登录验证码为<?php echo '{var}';?>。<br/></strong>
						    </div>				    
						</div>
						
						<!--<div class="layui-form-item">
						    <label class="layui-form-label" style="width: 145px;">团队验证码</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						    	<input type="checkbox" name="is_jxscode" lay-skin="switch" lay-text="必填|选填" <?php if($list['is_jxscode']==1){echo 'checked';} ?>>
						    </div>
						</div>-->
						<!--<div class="layui-form-item">
						    <label class="layui-form-label" style="width: 145px;">合作优势</label>
						    <div class="layui-input-block" style="margin-left: 145px;">
						    	<textarea class="layui-textarea" name="content">{$list['content']}</textarea>
						    </div>
						</div>-->
					  	<div style="height: 10px;"></div>
					</form>	
					<div class="layui-form-item">  
				  		<br/><br/> 
				   	 	<div class="layui-input-block" style="text-align: center;margin-left: 0;">
				      		<button class="layui-btn" type="button" onclick="subform('system')" style="margin-bottom: 50px;">立即提交</button>
				    	</div>
				  	</div>
				</div>
			</div>
		</div>
	</div>
	<include file="Public/footer.html" />
	<script src="__ROOT__/Public/js/tools.js" charset="utf-8"></script>
	<script>			
		//监听提交
		layui.use(['form','element','layer','upload'], function(){
	    	var upload = layui.upload;
	    	//执行实例
			var uploadInst = upload.render({
			    elem: '#upload_kf' //绑定元素
			    ,url: "{:U('Home/Web/System/do_upload')}" //上传接口
			    ,done: function(res){
			    	//上传完毕回调
			    	console.log(res);
			    	$('#kf_img').attr('src',res.path);
			    	$('#kf_img_val').val(res.path);
			    }
			    ,error: function(){
			    	//请求异常回调
			    }
			});
			
			var uploadInst = upload.render({
			    elem: '#upload_posters' //绑定元素
			    ,url: "{:U('Home/Web/System/do_upload')}" //上传接口
			    ,done: function(res){
			    	//上传完毕回调
			    	console.log(res);
			    	$('#posters').attr('src',res.path);
			    	$('#posters_val').val(res.path);
			    }
			    ,error: function(){
			    	//请求异常回调
			    }
			});
		});
		
		function subform(flag){
			var tjing = layer.msg('提交中...', {icon: 16,shade: 0.3,time: 60*1000});
	        var form=document.querySelector("#"+flag);
	    	var formData = new FormData(form);
	    	var appid = $('input[name="appid"]').val();
	    	var secret = $('input[name="secret"]').val();
	    	var login_type = $('.login_type').val();
	    	if(!appid && login_type==1){
	    		layer.msg('appid不能为空', {icon: 2,offset: '40%',time: 2000,shade: 0.3})
	    		return false;
	    	}
	    	if(!secret && login_type==1){
	    		layer.msg('secret不能为空', {icon: 2,offset: '40%',time: 2000,shade: 0.3})
	    		return false;
	    	}
		    formData.append("flag",flag);
			$.ajax({
				type: 'POST',
				url: "{:U('Home/Web/System/do_system')}",
				 data :formData,
		         dataType:"text",
		         processData : false,         
		         contentType : false,   
				 success: function(data) {
				 	layer.close(tjing);
					if(data == '1') {
              	 		var index = layer.getFrameIndex(window.name);
						layer.msg('提交成功', {icon: 1,offset: '40%',time: 2000,shade: 0.3}, function() {
			       		window.location.href="{:U('Home/Web/System/system')}&flag="+flag;
						});
					} else if(data == '2') {
						layer.msg('提交失败', {icon: 2,offset: '40%',time: 2000,shade: 0.3})
					}else{
						layer.msg(data, {icon: 2,offset: '40%',time: 2000,shade: 0.3});
					}
				}
			});
		}
	</script>
</body>
</html>